import { loadGltf, loadGltfAndCreateInstanceMeshWithMatrixWorld } from '../three-utils';
import * as THREE from 'three';
/**
 * 加载厂房
 * @returns
 */
// 使用优化后的函数加载不同的模型
//-地板
const loadPlantFllor = (): Promise<THREE.InstancedMesh | null> => {
  const matrixWorldArray = [
    [
      8.722733736488697e-11, -4.361363878729377e-11, 0.0014634326651219512, 0,
      -0.001463432548706534, -6.978190177472023e-10, 3.0529579036925367e-10, 0,
      4.797505344077421e-10, -0.0014634325487065652, -2.6168220964254175e-10, 0, 5.539968013763428,
      -0.18344534933567047, -0.8607666492462158, 1,
    ],
    [
      8.722733736488697e-11, -4.361363878729377e-11, 0.0014634326651219512, 0,
      -0.001463432548706534, -6.978190177472023e-10, 3.0529579036925367e-10, 0,
      4.797505344077421e-10, -0.0014634325487065652, -2.6168220964254175e-10, 0, 5.538029670715332,
      -0.18344534933567047, -1.9263529777526855, 1,
    ],
  ];
  return loadGltfAndCreateInstanceMeshWithMatrixWorld({
    modelPath: '/model/plant/fllor.glb',
    matrixWorldArray,
  });
};
//-地板1
const loadPlantFllor1 = () => {
  return loadGltf({
    modelPath: '/model/plant/fllor1.glb',
  }).then((gltf) => {
    const group = gltf.scene;
    return group;
  });
};
//-房子
const loadPlantHouser = () => {
  return loadGltf({
    modelPath: '/model/plant/house.glb',
  }).then((gltf) => {
    const group = gltf.scene;
    return group;
  });
};

// 厂房-底座
const loadWorkshop = (): Promise<THREE.InstancedMesh | null> => {
  const matrixWorldArray = [
    [
      1.7445470420502703e-10, -8.722729491178777e-11, 0.0014634328251509898, 0,
      -0.001463432475904837, -8.722737495874543e-10, 4.3613680720470376e-10, 0,
      6.105915425645588e-10, -0.0014634324759048994, -3.4890963709269076e-10, 0, 5.799161911010742,
      -0.10175332427024841, -2.2711143493652344, 1,
    ],
    [
      1.7445470420502703e-10, -8.722729491178777e-11, 0.0014634328251509898, 0,
      -0.001463432475904837, -8.722737495874543e-10, 4.3613680720470376e-10, 0,
      6.105915425645588e-10, -0.0014634324759048994, -3.4890963709269076e-10, 0, 5.799161911010742,
      -0.1017533391714096, -1.6770743131637573, 1,
    ],
    [
      1.7445470420502703e-10, -8.722729491178777e-11, 0.0014634328251509898, 0,
      -0.001463432475904837, -8.722737495874543e-10, 4.3613680720470376e-10, 0,
      6.105915425645588e-10, -0.0014634324759048994, -3.4890963709269076e-10, 0, 5.799161911010742,
      -0.1017533391714096, -1.1166938543319702, 1,
    ],
    [
      1.7445470420502703e-10, -8.722729491178777e-11, 0.0014634328251509898, 0,
      -0.001463432475904837, -8.722737495874543e-10, 4.3613680720470376e-10, 0,
      6.105915425645588e-10, -0.0014634324759048994, -3.4890963709269076e-10, 0, 5.799161911010742,
      -0.1017533391714096, -0.5251810550689697, 1,
    ],
  ];
  return loadGltfAndCreateInstanceMeshWithMatrixWorld({
    modelPath: '/model/plant/workshop.glb',
    matrixWorldArray,
  });
};

// 厂房-屋顶
const loadWorkshopRooft = (): Promise<THREE.InstancedMesh | null> => {
  const matrixWorldArray = [
    [
      1.7445470420502703e-10, -8.722729491178777e-11, 0.0014634328251509898, 0,
      -0.001463432475904837, -8.722737495874543e-10, 4.3613680720470376e-10, 0,
      6.105915425645588e-10, -0.0014634324759048994, -3.4890963709269076e-10, 0, 5.790809631347656,
      -0.03928171098232269, -2.269547462463379, 1,
    ],
    [
      1.7445470420502703e-10, -8.722729491178777e-11, 0.0014634328251509898, 0,
      -0.001463432475904837, -8.722737495874543e-10, 4.3613680720470376e-10, 0,
      6.105915425645588e-10, -0.0014634324759048994, -3.4890963709269076e-10, 0, 5.790809631347656,
      -0.03928172588348389, -1.6786420345306396, 1,
    ],
    [
      1.7445470420502703e-10, -8.722729491178777e-11, 0.0014634328251509898, 0,
      -0.001463432475904837, -8.722737495874543e-10, 4.3613680720470376e-10, 0,
      6.105915425645588e-10, -0.0014634324759048994, -3.4890963709269076e-10, 0, 5.790809631347656,
      -0.03928172588348389, -1.1182615756988525, 1,
    ],
    [
      1.7445470420502703e-10, -8.722729491178777e-11, 0.0014634328251509898, 0,
      -0.001463432475904837, -8.722737495874543e-10, 4.3613680720470376e-10, 0,
      6.105915425645588e-10, -0.0014634324759048994, -3.4890963709269076e-10, 0, 5.790809631347656,
      -0.03928172588348389, -0.526748776435852, 1,
    ],
  ];
  return loadGltfAndCreateInstanceMeshWithMatrixWorld({
    modelPath: '/model/plant/workshopRooft.glb',
    matrixWorldArray,
  });
};

//-围栏
const loadPlantRail = (): Promise<THREE.InstancedMesh | null> => {
  const matrixWorldArray = [
    [
      1.7445470420502703e-10, -8.722729491178777e-11, 0.0014634328251509898, 0,
      -0.001463432475904837, -8.722737495874543e-10, 4.3613680720470376e-10, 0,
      6.105915425645588e-10, -0.0014634324759048994, -3.4890963709269076e-10, 0, 5.648107528686523,
      -0.16513817012310028, -1.9267308712005615, 1,
    ],
    [
      1.7445470420502703e-10, -8.722729491178777e-11, 0.0014634328251509898, 0,
      -0.001463432475904837, -8.722737495874543e-10, 4.3613680720470376e-10, 0,
      6.105915425645588e-10, -0.0014634324759048994, -3.4890963709269076e-10, 0, 5.648107528686523,
      -0.16513817012310028, -0.7750213146209717, 1,
    ],
  ];
  return loadGltfAndCreateInstanceMeshWithMatrixWorld({
    modelPath: '/model/plant/rail.glb',
    matrixWorldArray,
  });
};

export {
  loadPlantFllor,
  loadPlantFllor1,
  loadPlantHouser,
  loadWorkshop,
  loadWorkshopRooft,
  loadPlantRail,
};
